package cn.pconline.autoclub.entity;

import cn.pconline.autoclub.util.EncodeUtils;
import cn.pconline.autoclub.util.WebUtils;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Label;

@Entity(tableName = "ac_dyna_reply", 
logChange = true, split = "Mod:dynaInfoId:10")
@Label("动态回复")
public class DynaReply {

    @Id
    @Label("回复id")
    @Column(name = "dyna_reply_id")
    private long dynaReplyId;
    @Label("动态id")
    @Column(name = "dyna_info_id")
    private long dynaInfoId;
    @Label("动态类型：1-帖子，2-动态")
    @Column(name = "type")
    private int type;
    public static final int TYPE_TOPIC = 1;
    public static final int TYPE_COMMENT = 2;
    @Label("内容")
    @Column(name = "content")
    private String content;
    @Label("主题id")
    @Column(name = "topic_id")
    private long topicId;
    @Label("回复帖子id")
    @Column(name = "post_id")
    private long postId;
    @Label("回复帖子楼层")
    @Column(name = "floor")
    private int floor;
    @Label("回复时间")
    @Column(name = "create_date")
    private Date createDate;
    @Label("回复者ID")
    @Column(name = "create_by")
    private long createBy;
    @Label("回复者昵称")
    @Column(name = "create_name")
    private String createName;
    @Label("被回复动态回复id")
    @Column(name = "post_to_dyna_reply_id")
    private long postToDynaReplyId;
    @Label("被回复帖子id")
    @Column(name = "post_to_post_id")
    private long postToPostId;
    @Label("被回复人id")
    @Column(name = "post_to_user_id")
    private long postToUserId;
    @Label("被回复人昵称")
    @Column(name = "post_to_nick_name")
    private String postToNickName;
    @Label("回复帖子楼层")
    @Column(name = "post_to_floor")
    private int postToFloor;
    @Label("状态 1:正常状态 -1:删除状态")
    @Column(name = "status")
    private int status;
    public static final int STATUS_NORMAL = 1;
    public static final int STATUS_DELETE = -1;
    //目前回复都是没有图片的，默认为0
    @Label("是否有图片 1:有， 0:无")
    @Column(name = "is_pic")
    private int isPic;
    public static final int PIC_NOT = 0;
    @Label("审核状态：0未审，1：审核通过 -1：审核未通过")
    @Column(name = "censored")
    private int censored;
    public static final int CENSORED_PASS = 1;
    public static final int CENSORED_NOTPASS = -1;
    public static final int CENSORED_UNDO = 0;
    @Label("更新者")
    @Column(name = "update_by")
    private long updateBy;
    @Label("创建时间")
    @Column(name = "create_at")
    private Date createAt;
    @Label("更新时间")
    @Column(name = "update_at")
    private Date updateAt;

    public long getDynaReplyId() {
        return dynaReplyId;
    }

    public void setDynaReplyId(long dynaReplyId) {
        this.dynaReplyId = dynaReplyId;
    }

    public long getDynaInfoId() {
        return dynaInfoId;
    }

    public void setDynaInfoId(long dynaInfoId) {
        this.dynaInfoId = dynaInfoId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getFilteredContent() {
        return WebUtils.transformToBBSFaceThenLimit(content, 150);
    }

    public boolean getFilteredContentLimit() {
        int len = WebUtils.countEmotLength(WebUtils.replaceNewLine(content), 150);
        return len > 0;
    }

    public long getTopicId() {
        return topicId;
    }

    public void setTopicId(long topicId) {
        this.topicId = topicId;
    }

    public long getPostId() {
        return postId;
    }

    public void setPostId(long postId) {
        this.postId = postId;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(long createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public long getPostToDynaReplyId() {
        return postToDynaReplyId;
    }

    public void setPostToDynaReplyId(long postToDynaReplyId) {
        this.postToDynaReplyId = postToDynaReplyId;
    }

    public long getPostToPostId() {
        return postToPostId;
    }

    public void setPostToPostId(long postToPostId) {
        this.postToPostId = postToPostId;
    }

    public long getPostToUserId() {
        return postToUserId;
    }

    public void setPostToUserId(long postToUserId) {
        this.postToUserId = postToUserId;
    }

    public String getPostToNickName() {
        return postToNickName;
    }

    public void setPostToNickName(String postToNickName) {
        this.postToNickName = postToNickName;
    }

    public int getPostToFloor() {
        return postToFloor;
    }

    public void setPostToFloor(int postToFloor) {
        this.postToFloor = postToFloor;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getIsPic() {
        return isPic;
    }

    public void setIsPic(int isPic) {
        this.isPic = isPic;
    }

    public int getCensored() {
        return censored;
    }

    public void setCensored(int censored) {
        this.censored = censored;
    }

    public long getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(long updateBy) {
        this.updateBy = updateBy;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }

    public JSONObject getJSONObject(int source_agent) {
        JSONObject obj = new JSONObject();
        obj.put("censored", this.censored);
        obj.put("content", EncodeUtils.encodeForHTML(this.content, source_agent));
        obj.put("userId", this.createBy);
        obj.put("createAt", this.createAt);
        obj.put("createDate", this.createDate);
        obj.put("username", EncodeUtils.encodeForHTML(this.createName, source_agent));
        obj.put("dynaInfoId", this.dynaInfoId);
        obj.put("replyId", this.dynaReplyId);
        obj.put("floor", this.floor);
        obj.put("isPic", this.isPic);
        obj.put("postId", this.postId);
        obj.put("postToDynaReplyId", this.postToDynaReplyId);
        obj.put("postToFloor", this.postToFloor);
        //      obj.put("postToNickName",this.postToNickName == null ? "" : this.postToNickName);
        obj.put("postToPostId", this.postToPostId);
        obj.put("postToUserId", this.postToUserId);
        obj.put("status", this.status);
        obj.put("topicId", this.topicId);
        obj.put("type", this.type);
        obj.put("updateAt", this.updateAt);
        obj.put("updateBy", this.updateBy);
        return obj;
    }
}
